<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Organization Chart Plugin</title>
  <link rel="icon" href="img/logo.png">
  <link rel="stylesheet" href="css/jquery.orgchart.css">
  <link rel="stylesheet" href="css/style.css">
  <style type="text/css">
    #chart-container { height: 600px; }
    .orgchart { background: #fff; }
  </style>
</head>
<body>
  <div id="chart-container"></div>

  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/jquery.orgchart.js"></script>
  <script type="text/javascript" src="js/json-digger.js"></script>
  <script type="text/javascript">
    $(function() {

      var datascource = {
      'id': '1',
      'name': 'Lao Lao',
      'title': 'general manager',
      'children': [
        { 'id': '2', 'name': 'Bo Miao', 'title': 'department manager' },
        { 'id': '3', 'name': 'Su Miao', 'title': 'department manager',
          'children': [
            { 'id': '4', 'name': 'Tie Hua', 'title': 'senior engineer' },
            { 'id': '5', 'name': 'Hei Hei', 'title': 'senior engineer',
              'children': [
                { 'id': '6', 'name': 'Pang Pang', 'title': 'engineer' },
                { 'id': '7', 'name': 'Dan Dan', 'title': 'UE engineer' ,
                'children': [
                  { 'id': '8', 'name': 'Er Dan', 'title': 'engineer' },
                  { 'id': '9', 'name': 'San Dan', 'title': 'engineer',
                    'children': [
                      { 'id': '10', 'name': 'Si Dan', 'title': 'intern' },
                      { 'id': '11', 'name': 'Wu Dan', 'title': 'intern' }
                    ]
                  }
                ]}
              ]
            }
          ]
        },
        { 'id': '12', 'name': 'Hong Miao', 'title': 'department manager' },
        { 'id': '13', 'name': 'Chun Miao', 'title': 'department manager',
          'children': [
            { 'id': '14', 'name': 'Bing Qin', 'title': 'senior engineer' },
            { 'id': '15', 'name': 'Yue Yue', 'title': 'senior engineer',
              'children': [
                { 'id': '16', 'name': 'Er Yue', 'title': 'engineer' },
                { 'id': '17', 'name': 'San Yue', 'title': 'UE engineer' }
              ]
            }
          ]
        }
      ]
    };

    var oc = $('#chart-container').orgchart({
      'data' : datascource,
      'nodeContent': 'title',
      'draggable': true,
      'verticalLevel': 3
    });

    oc.$chart.on('nodedrop.orgchart', function(event, extraParams) {
      console.log('draggedNode:' + extraParams.draggedNode.children('.title').text()
        + ', dragZone:' + extraParams.dragZone.children('.title').text()
        + ', dropZone:' + extraParams.dropZone.children('.title').text()
      );
    });

  });
  </script>
  </body>
</html>